package acm.蓝桥13;

import java.util.Scanner;

public class 子矩阵优化 {
    /**
     * todo：重点
     * 二维压缩优化
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        int m=sc.nextInt();
        int k=sc.nextInt();
        long[][] sum=new long[n+1][m+1];  //存储每一列的值
        for (int i = 1; i < sum.length; i++) {
            for (int j = 1; j < sum[0].length; j++) {
                sum[i][j]=sc.nextInt()+sum[i-1][j];
            }
        }
        long res=0;
        for (int sx = 0; sx <= n; sx++) {
            for (int ex = sx+1; ex <= n; ex++) {
                long s=0;
                for (int i=1,j = 1; j <= m; j++) {
                    s+=sum[ex][j]-sum[sx][j];
                    while (i<=j&&s>k){
                        s-=sum[ex][i]-sum[sx][i];
                        i++;
                    }
                    res+=j-i+1;   //每次向窗口中新增一个元素，区间会增加(j-i+1)个
                }
            }
        }
        System.out.println(res);
    }
}
